﻿using System;

namespace WeChatJsSdk.SdkCore
{
    /// <summary>
    /// 日志工具类
    /// </summary>
    public class LogUtil
    {
        public static string loggerName = "log";
        
        public static void Debug(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
            if (log.IsDebugEnabled)
            {
                log.Debug(message);
            }

            log = null;
        }

        public static void Error(string message,Exception exception)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
            if (log.IsErrorEnabled)
            {
                log.Error(message, exception);
            }
            log = null;
        }

        public static void Fatal(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
            if (log.IsFatalEnabled)
            {
                log.Fatal(message);
            }
            log = null;
        }

        public static void Info(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(loggerName);
            if (log.IsInfoEnabled)
            {
                log.Info(message);
            }
            log = null;
        }

        public static void Warn(string message)
        {
            log4net.ILog log = log4net.LogManager.GetLogger(loggerName);

            if (log.IsWarnEnabled)
            {
                log.Warn(message);
            }
            log = null;
        }
    }
}
